package cn.iotnc.camera.api

import cn.iotnc.camera.model.PictureBody
import cn.iotnc.camera.util.DOMAIN_NAME
import okhttp3.ResponseBody
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST


interface CameraApi {

    @POST("/picture/get")
    suspend fun getPicture(
        @Header(DOMAIN_NAME) baseUrl: String,
        @Body body: PictureBody
    ): ResponseBody

    companion object {
        private const val PICTURE_REQUEST_HTTP_BASE_URL = "http://%s:8011"
        fun String.toBaseUrl() = String.format(PICTURE_REQUEST_HTTP_BASE_URL, this)
    }
}